FROM registry.cn-zhangjiakou.aliyuncs.com/cgspublic/golang:1.23.7-alpine3.21 AS builder

LABEL stage=gobuilder

ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build

COPY . .
RUN rm -f go.work go.work.sum
RUN go build -o  /app/saveit

FROM registry.cn-zhangjiakou.aliyuncs.com/cgspublic/alpine:3.21.3
#RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list
#RUN apt update && apt install -y ttf-wqy-zenhei
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /app/saveit /app/saveit
COPY index.html /app/index.html
ENTRYPOINT []
CMD ["./saveit"]
